/**
 * 
 */
package com.gr.staffpm.pages.tasks.model;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;

import com.gr.staffpm.pages.tasks.ViewTask;

/**
 * @author Graham Rhodes 1 Jan 2011 14:56:16
 */
public class AjaxCloseOpenTaskLink extends AjaxLink<Void> {

    private static final long serialVersionUID = 1L;
    private final ViewTask viewTask;

    public AjaxCloseOpenTaskLink(ViewTask viewTask) {
        super("link");
        this.viewTask = viewTask;
    }

    /* (non-Javadoc)
     * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
     */
    @Override
    public void onClick(AjaxRequestTarget target) {
        if (viewTask.getTask().getStatus().getValue().equals("Closed")) {
            viewTask.openTask(target);
        } else {
            viewTask.closeTask(target);
        }
    }

}
